import math

from seaman.core import JsonUtil


class OilWellData:
    # 测井深度
    depth: float
    # 倾斜角
    inclination: float
    # 井斜角变化率
    inclination_rate: float
    # 方位角
    azimuth: float
    # 方位角变化率
    azimuth_rate: float
    # 垂直井深 TVD 即三维坐标系中 Z
    true_vertical_depth: float
    # 狗腿度 DLS
    dog_leg_severity: float
    # 北向偏移 North 即三维坐标系中 X
    north: float
    # 东向偏移 East 即三维坐标系 Y
    east: float
    # 全角
    full_angle: float
    # 工具面角度
    face_angle: float
    # 圆弧角
    arc_angle: float
    # 曲率半径
    curvature_radius: float

    def __init__(self):
        pass

    def __str__(self):
        return JsonUtil.obj2str(self)


# 获取深度增量
def get_delta_depth(a: OilWellData, b: OilWellData) -> float:
    return a.depth - b.depth


# 计算方位角增量
def get_delta_azimuth(a: OilWellData, b: OilWellData) -> float:
    return a.azimuth - b.azimuth


# 度数转弧度
def degree_to_radian(degree: float) -> float:
    radian = math.radians(degree)
    return radian


# 数据处理
def roundOilWellData(data: OilWellData) -> OilWellData:
    t = OilWellData()
    t.depth = data.depth
    t.inclination = round(data.inclination, 3)
    t.azimuth = round(data.azimuth, 5)
    t.north = round(data.north, 5)
    t.east = round(data.east, 5)
    t.true_vertical_depth = round(data.true_vertical_depth, 3)
    t.full_angle = round(data.full_angle, 3)
    t.arc_angle = round(data.arc_angle, 3)
    t.face_angle = round(data.face_angle, 3)
    t.dog_leg_severity = round(data.dog_leg_severity, 4)
    t.curvature_radius = round(data.curvature_radius, 5)
    t.inclination_rate = round(data.inclination_rate, 4)
    t.azimuth_rate = round(data.azimuth_rate, 4)
    return t


class RockFormationData:
    # 测井深度
    depth: float
    # 倾斜角
    inclination: float
    # 方位角
    azimuth: float
    # 岩石内聚力
    cohesion: float
    # 岩石内摩擦角
    internal_friction_angle: float
    # 地层应力系数
    formation_stress_factor: float
    # 泊松比
    poisson_ratio: float
    # 最大水平地应力
    max_horizontal_ground_stress: float
    # 最小水平地应力
    min_horizontal_ground_stress: float
    # 上覆岩层压力
    overburden_pressure: float
    # 原始孔隙压力
    in_situ_pore_pressure: float
    # 井眼半径
    borehole_radius: float
    # 孔隙度
    void_ratio: float
    # 钻井液滤失量
    fluid_loss: float
    # 钻井液粘度
    drilling_fluid_viscosity: float
    # 弹性储容比
    elastic_storage_ratio: float
    # 煤岩导压系数
    conductivity_coefficient: float
    # 钻井液渗流时间
    drilling_fluid_seepage_time: float
    # 渗透率
    permeability: float
    # 岩层厚度
    rock_thickness: float
    # 渗透系数
    osmotic_coefficient: float


class CableMechanicsData:
    # 电缆工具外径
    cable_tool_outer_diameter: float
    # 流体密度
    drilling_fluid_density: float
    # 表面流速
    surface_flow_velocity: float
    # 套管内径
    casing_inner_diameter: float
    # 牛顿系数
    newton_coefficient: float
    # 电缆的弹性模量
    cable_tool_elastic_modulus: float
    # 电缆线重
    cable_tool_line_weight: float
    # 流体动力粘度
    hydrodynamic_viscosity: float
    # 电缆工具长度
    cable_tool_length: float
    # 电缆工具密度
    cable_tool_density: float
    # 体积因子
    volume_factor: float
    # 环空系数
    annulus_coefficient: float
    # 摩擦系数
    friction_coefficient: float
    # 电缆的惯性矩
    cable_tool_inertia_moment: float
    # 电缆的外径
    cable_outer_diameter: float
    # 电缆材料的许用应力
    cable_material_allowable_stress: float
    # 微元段长度
    microelement_segment_length: float
    # 安全系数
    safety_factor: float
